package com.dp.pub;

import java.io.IOException;
import java.util.Properties;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.context.support.WebApplicationContextUtils;

import com.dp.tj.JobScheduler;

//import com.dp.tj.JobScheduler;//去掉Quartz

//import com.wht.mVO;
//import com.wht.vomethod;

//import javax.naming.Context;
//import javax.naming.InitialContext;
//import javax.sql.DataSource;
//import java.sql.Statement;
//import java.sql.ResultSet;
//import java.sql.Connection;
//import java.sql.PreparedStatement;
//import java.sql.Driver;
//import java.sql.DriverManager;

//
//import net.sf.hibernate.SessionFactory;
//import net.sf.hibernate.Session;
//import com.wht.Cat;
//import com.hurray.dreamcard.model.daoimpl.HUtil;
 // import org.hibernate.cfg.Configuration;
//import org.hibernate.SessionFactory;
public class ForInit extends HttpServlet
{
	
 
  public void init(ServletConfig config)
  {
	//  Configuration cf=null;
	//  SessionFactory sf=null;

  	try{
  	//	cf=new Configuration();
  	//	//cf.configure("E:\\resin-3.0.6\\deploy\\keer8\\hibernate1.cfg.xml");
  	    //  
  		
  		// HUtil.initSessionFactory(cf.configure("/hibernate.cfg.xml")
  				                     //.configure("/hibernate.cfg2.xml")
  				                     //.configure("/hibernate.cfg3.xml")
  	//			                     .buildSessionFactory());
 //
  	System.out.println("init");
  	
  	
  
  	/*
  	    wappush.PushProxyUrl=http://211.94.72.138:8380/
  		wappush.AddressDomain=www.hurraytimes.com
  		wappush.PushProxyUser=user
  		wappush.PushProxyPassword=user
  		wappush.PushSender=www.hurraytimes.com
  		wappush.timer=0/20 * * * * ? *
  	*/
  	//System.setProperty(key, value)
  
//	Properties p=new Properties();
//  	p.load(this.getClass().getResource("/c.properties").openStream());
//  //Set s=	;
//  for(Object o:p.keySet())
//  {
//	  System.setProperty((String)o, (String)p.getProperty((String)o));
//	  System.out.print((String)o);
//	  System.out.println((String)p.getProperty((String)o));
//  }
  MyServer.ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext());
//	new JobScheduler().createjob();//去掉Quartz
  	
  	//p.list(System.out);
	//System.out.println(.toString());
  //	forinit(String s:p.keySet<String>())
  //	{
  //		
  //	}
	
  	
  //	String prefix = config.getServletContext().getRealPath("/");
  //	System.out.println(prefix);
  	//GlobalProp.setPath(prefix+"classes"+File.separator);
  //	GlobalProp gp=new GlobalProp();  	
 // 	gp.setPath();
  	
  //	CheckJMS.reset();
  	
  	 }catch(Exception e){

  		  e.printStackTrace();
  		  }
  	//System.out.println(GlobalProp.getPrep("row"));
  	
  	
/*  	String prefix = config.getServletContext().getRealPath("/");
    String file = config.getInitParameter("log4j.properties");
    String filePath = prefix + file;
    Properties props = new Properties();
    try {
        FileInputStream istream = new FileInputStream(filePath);
        props.load(istream);
        istream.close();
        //toPrint(props.getProperty("log4j.appender.file.File"));
        String logFile = prefix + props.getProperty("log4j.appender.file.File");
        props.setProperty("log4j.appender.file.File",logFile);
        PropertyConfigurator.configure(props);//
    } catch (IOException e) {
        toPrint("Could not read configuration file [" + filePath + "].");
        toPrint("Ignoring configuration file [" + filePath + "].");
        return;*/
   // }

  	
  }
  public void doGet(HttpServletRequest req, HttpServletResponse res)   throws IOException, ServletException
  {    
  }
  public void doPost(HttpServletRequest req, HttpServletResponse res)  throws IOException, ServletException
  {
//    res.setContentType("text/html ; charset=gb2312");
//    res.setHeader("Pragma", "no-cache");
//    PrintWriter out=res.getWriter();
//    try{ ctx = new InitialContext();
//    SessionFactory sf = (SessionFactory) ctx.lookup("hibernate/session_factory");
//    Session ss=sf.openSession();
//       }
  }
  
  public void destroy()
  {
	 // CheckJMS.stop();
  }
}


